The code fragment in Example 4-1 illustrates how to set OpenGL state so that subsequent calls to glDrawPixels() or glCopyPixels() will be fast.
Example 4-1 : Drawing Pixels Fast
/* * Disable stuff that's likely to slow down * glDrawPixels.(Omit as much of this as possible, * when you know in advance that the OpenGL state is * already set correctly.) */ glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_DITHER); glDisable(GL_FOG); glDisable(GL_LIGHTING); glDisable(GL_LOGIC_OP); glDisable(GL_STENCIL_TEST); glDisable(GL_TEXTURE_1D); glDisable(GL_TEXTURE_2D); glPixelTransferi(GL_MAP_COLOR, GL_FALSE); glPixelTransferi(GL_RED_SCALE, 1); glPixelTransferi(GL_RED_BIAS, 0); glPixelTransferi(GL_GREEN_SCALE, 1); glPixelTransferi(GL_GREEN_BIAS, 0); glPixelTransferi(GL_BLUE_SCALE, 1); glPixelTransferi(GL_BLUE_BIAS, 0); glPixelTransferi(GL_ALPHA_SCALE, 1); glPixelTransferi(GL_ALPHA_BIAS, 0); /* * Disable extensions that could slow down * glDrawPixels.(Actually, you should check for the * presence of the proper extension before making * these calls.I omitted that code for simplicity.) */ #if GL_SGI_index_func (glDisable(GL_INDEX_TEST_SGI); #endif